<?php

namespace JLPay\Services\Marketing;

use JLPay\Services\BaseService;
use JLPay\Models\Marketing\MerchantActivityUpdateRequest;
use JLPay\Models\Marketing\MerchantActivityUpdateResponse;

/**
 * 商户活动更新服务
 */
class MerchantActivityUpdateService extends BaseService
{
    /**
     * 获取API URL
     *
     * @param string $requestClass 请求类
     * @param string|null $apiPath 接口路径
     * @return string 完整的API URL
     */
    public function getApiUrl(string $requestClass, ?string $apiPath = null): string
    {
        $baseUrl = $this->config->getUrl();
        
        if ($apiPath) {
            return $baseUrl . $apiPath;
        }
        
        // 使用Request类中定义的path()方法
        if (class_exists($requestClass) && method_exists($requestClass, 'path')) {
            $request = new $requestClass();
            $apiPath = $request->path();
            return $baseUrl . $apiPath;
        }
        
        // 如果没有定义path方法，使用默认路径
        return $baseUrl . "/open/org/bank/act-bridge/act-merch-relation/update";
    }
    
    /**
     * 商户活动更新接口
     *
     * @param MerchantActivityUpdateRequest $request 请求对象
     * @return MerchantActivityUpdateResponse 响应对象
     */
    public function merchantActivityUpdate(MerchantActivityUpdateRequest $request): MerchantActivityUpdateResponse
    {
        return $this->post($request, MerchantActivityUpdateResponse::class);
    }
} 